﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;
using System.IO;
using System.Dynamic;
using FluorineFx.Json;

namespace lxwmvc
{
    /// <summary>
    /// 资金冻结解冻
    /// </summary>
    public static partial class huifucontroller
    {

        #region 资金冻结解冻
        /// <summary>
        /// 资金解冻，提现复核时自动需要解冻
        /// </summary>
        /// <param name="TrxId">冻结金额时生成的TrxId</param>
        public static void huifu_jiedongjine(string TrxId)
        {
            //解冻
            UsrUnFreeze obj = new UsrUnFreeze();
            obj.MerCustId = HuiFuArg.MerCustId;
            //冻结金额时生成的TrxId
            obj.TrxId = TrxId;
            //后台通知
            obj.BgRetUrl = HuiFuArg.LocalUrl + "huifu/huifu_jiedongjine_returnbg";
            
            var ret = core_huifu.Send<RetUsrUnFreeze>(obj);
            {
                core_huifu.saveHuiFuLiuShui(ret);               
            }
        }
       
        /// <summary>
        /// 冻结金额
        /// </summary>
        /// <param name="UsrCustId">用户编号</param>
        /// <param name="TransAmt">冻结金额</param>
        /// <param name="Mdrawmoneyid"></param>
        public static void huifu_dongjiejine(string UsrCustId, string TransAmt, int Mdrawmoneyid)
        {
            //没有需要冻结的信息
            if (Mdrawmoneyid <= 0) return;
            //冻结金额
            UsrFreezeBg objsend = new UsrFreezeBg();
            objsend.UsrCustId = UsrCustId + "";
            objsend.MerCustId = HuiFuArg.MerCustId;
          
            objsend.TransAmt = TransAmt.todecimal().ToString("#0.00") + "";
            objsend.BgRetUrl = HuiFuArg.LocalUrl + "huifu/huifu_dongjiejine_returnbg";
            var tobjrevcash = core_huifu.Send<RetUsrFreezeBg>(objsend);
            {                
                core_huifu.saveHuiFuLiuShui(tobjrevcash);

                //更新冻结编号
                supermodel.create("Mdrawmoney")
                    .set("TrxId", tobjrevcash.TrxId)
                    .where("Mdrawmoneyid=" + Mdrawmoneyid)
                    .update();
            }
        }

        /// <summary>
        /// 汇付，冻结金额后台返回通知,所有的后台通知，都必须跳过验证功能
        /// </summary>
        public static void huifu_dongjiejine_returnbg(pagebase pb)
        {
            RetUsrUnFreeze objrev = new RetUsrUnFreeze();
            //后台调用，最终要打印出来参数
            core_huifu.ReturnUrl(HttpContext.Current, "OrdId", objrev, true);
        }

        /// <summary>
        /// 解冻后台返回通知
        /// </summary>
        /// <param name="pb"></param>
        public static void huifu_jiedongjine_returnbg(pagebase pb)
        {
            RetUsrFreezeBg objrev = new RetUsrFreezeBg();
            //后台调用，最终要打印出来参数
            core_huifu.ReturnUrl(HttpContext.Current, "OrdId", objrev, true);
        }
        #endregion
    }
}